#!/usr/bin/env node
import { program } from "commander";
import { createRequire } from "module";
import { fileURLToPath } from "url";
import { dirname, join } from "path";
import { create } from "./command/create.js";
import chalk from "chalk";
const require = createRequire(import.meta.url);
const __dirname = fileURLToPath(import.meta.url);
const __filename = dirname(__dirname);
const myCli = "my-cli"

const pkg = require(join(__filename, "../package.json"));

program.name(myCli).version(`${myCli}@${pkg.version}`).usage("<command> [option]");
program
  .command("create <project-name>")
  .description("创建项目模版")
  .option("-f, --force", "overwrite project")
  .action((name, opt) => {
    create(name, opt)
  });
program.addHelpText("after", `\nRun ${chalk.blueBright(`${myCli} <command> --help`)} for detailed usage of given command`)
program.parse(process.argv);
